Tool Results
BindAI tools useToolResult as their execution result type.
ToolResult records:
- whether execution succeeded
- the value produced by the tool
- an error message when execution failed
ToolResult
The V1ToolResult is a dataclass that extends BindAI’s ExecutionResult:
ToolResult uses slots=True.
The important distinction is:
- successful execution is represented by
success=True - the successful result is stored in
value - failed execution is represented by
success=False - failure information is stored in
error
Creating Successful Results
ToolResult provides the ok() class method for creating a successful result:
None in value does not by itself indicate failure.
Always use result.success to determine whether execution succeeded.
Creating Failed Results
ToolResult also provides the failed() class method:
failed() method accepts the failure message as a string.
For example:
Tool Implementations
TheTool base class defines the execution contract for class-based tools.
A Tool implementation provides:
namedescriptiondefinitionexecute(context)
execute() method returns a ToolResult:
Checking Success
Applications can inspect thesuccess field:
ToolResult.
For example:
value is None.
A successful tool can legitimately return:
Accessing the Returned Value
A successful tool value is available throughvalue:
ToolResult for the tool’s successful value is:
ToolResult directly.
Because ToolResult also extends ExecutionResult, BindAI’s broader execution-result interface can expose additional execution information where appropriate. The tool-specific successful value remains result.value.
Returning Different Python Values
Tools can produce normal Python values.Strings
Numbers
Lists
Dictionaries
ToolResult.value accepts arbitrary Python values.
The value should nevertheless be chosen with its downstream consumer in mind, particularly when the result will be passed into another workflow node or exposed through the Studio API.
None as a Successful Value
A tool can successfully complete without producing a meaningful value.
For example:
Handling Tool Failures
A tool failure can be represented explicitly:Exceptions and Tool Results
ATool implementation controls the ToolResult returned from its execute() method.
For example:
Tool Results in Workflows
Tools can be executed as workflow nodes. A Tool node can produce aToolResult that becomes part of workflow execution state.
Conceptually:
ToolResult object in workflow variables.
This is important because workflow execution state is richer than the JSON representation returned by the Studio API.
For example, a tool result can be stored as:
Tool Results and Parameter Mapping
When a Tool node is used in a workflow, its inputs can be mapped from workflow variables. For example:ToolResult represents the result of the tool execution.
Agent and Tool Results
Tool results and agent results serve different purposes. A tool execution uses:ToolResult, use:
Tool Results and Connection-backed Tools
BindAI V1 also usesToolResult for connection-backed tools.
For example, the V1 Webhook connection is exposed to workflows as a connection-backed tool.
Its tool implementation returns a ToolResult:
Studio API Representation
The workflow runtime can contain rich Python objects such asToolResult.
The Studio HTTP API converts these runtime values into JSON-safe data before returning them to an API client.
For a successful ToolResult, the Studio API exposes the underlying successful value.
For example, a runtime result such as:
ToolResult is represented with failure information.
For example:
ToolResult contract.
ToolResult and ExecutionResult
ToolResult extends BindAI’s ExecutionResult:
Current API
The verified V1ToolResult API is:
What Is Not Part of the V1 ToolResult API
The V1 API does not require a separateToolExecutor abstraction.
There is no verified V1 executor.py implementation in bindai-tool.
Therefore, application code should not depend on an API such as:
Predictable Tool Values
Tool outputs should be designed with their downstream consumers in mind. For structured operations, predictable dictionaries can be useful:Error Messages
Tool errors can flow into workflows, applications, or API responses. Avoid exposing sensitive information such as:- API keys
- access tokens
- passwords
- connection credentials
- private connection strings
- sensitive personal information
Testing Tool Results
Tools should be tested for both successful and failed execution. A successful result:None value:
None as failure.
Best Practices
- Use
ToolResult.ok(...)for successful class-based tool execution. - Use
ToolResult.failed(...)for explicit tool failures. - Check
result.successbefore consuming the result. - Read successful values from
result.value. - Read failure information from
result.error. - Do not use
value is Noneas the success test. - Keep tool output structures predictable.
- Keep error messages useful but safe.
- Do not expose credentials or sensitive data through errors.
- Test both successful and failed execution.
- Remember that
ToolResultextendsExecutionResult. - Treat workflow
ToolResultvalues as runtime objects rather than assuming they are already JSON. - Let the Studio API perform the JSON conversion at the HTTP boundary.
Complete Example
A class-based tool can returnToolResult directly:
Summary
ToolResult is BindAI’s V1 result type for tool execution.
Its core structure is:
ToolResult extends ExecutionResult, allowing tool results to participate in BindAI’s broader execution model.
In workflows, the runtime can preserve the full ToolResult object, while the Studio API converts runtime values into JSON-safe responses for HTTP clients.
The result contract therefore remains consistent across project tools, workflow Tool nodes, and the V1 Webhook connection-backed tool.